'use strict';

const path = require('path');

module.exports = appInfo => {
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1544004049388_6492';

  // add your config here
  config.middleware = [];

  // mysql
  config.mysql = {
    client: {
      host: 'rm-bp1aexkc058mh2o061o.mysql.rds.aliyuncs.com',
      port: '3306',
      user: 'schedule',
      password: 'Fantasia455163',
      database: 'schedule',
    },
    app: true,
    agent: false,
  };

  // 静态文件
  config.static = {
    prefix: '/',
    dir: path.join(appInfo.baseDir, 'app/public'),
    dynamic: true,
    preload: false,
    buffer: false,
    maxFiles: 10000,
  };

  // 视图层
  config.view = {
    root: path.join(appInfo.baseDir, 'app/view'),
    defaultViewEngine: 'nunjucks',
    defaultExtension: '.nunjucks',
  };

  // 取消csrf校验
  config.security = {
    csrf: {
      ignore: '/*',
    },
  };

  // 文件上传
  config.multipart = {
    fileSize: '10mb',
    whitelist: [
      '.xlsx',
    ],
  };

  return config;
};
